﻿using System;

namespace Arex
{
    public static class Factory
    {
        /// <summary>
        /// Create one dimensional array of integer values.
        /// </summary>
        /// <param name="cols">Number of elements (columns) in array.</param>
        /// <returns>One dimensional array of integers.</returns>
        public static int[] CreateInt1D(int cols)
        {
            if (cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            return new int[cols];
        }

        /// <summary>
        /// Create two dimensional array of integer values.
        /// </summary>
        /// <param name="rows">Number of rows in array.</param>
        /// <param name="cols">Number of columns in array.</param>
        /// <returns>Two dimensional array of integers.</returns>
        public static int[][] CreateInt2D(int rows, int cols)
        {
            if (rows < 0 || rows > Int32.MaxValue||cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            int[][] z = new int[rows][];
            for (int i = 0; i < rows; i++)
                z[i] = new int[cols];
            return z;
        }

        /// <summary>
        /// Create one dimensional array of long integer values.
        /// </summary>
        /// <param name="cols">Number of elements (columns) in array.</param>
        /// <returns>One dimensional array of long integers.</returns>
        public static long[] CreateLong1D(int cols)
        {
            if (cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            return new long[cols];
        }

        /// <summary>
        /// Create two dimensional array of long integer values.
        /// </summary>
        /// <param name="rows">Number of rows in array.</param>
        /// <param name="cols">Number of columns in array.</param>
        /// <returns>Two dimensional array of long integers.</returns>
        public static long[][] CreateLong2D(int rows, int cols)
        {
            if (rows < 0 || rows > Int32.MaxValue || cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            long[][] z = new long[rows][];
            for (int i = 0; i < rows; i++)
                z[i] = new long[cols];
            return z;
        }

        /// <summary>
        /// Create one dimensional array of float values.
        /// </summary>
        /// <param name="cols">Number of elements (columns) in array.</param>
        /// <returns>One dimensional array of floats.</returns>
        public static float[] CreateFloat1D(int cols)
        {
            if (cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            return new float[cols];
        }

        /// <summary>
        /// Create two dimensional array of float values.
        /// </summary>
        /// <param name="rows">Number of rows in array.</param>
        /// <param name="cols">Number of columns in array.</param>
        /// <returns>Two dimensional array of floats.</returns>
        public static float[][] CreateFloat2D(int rows, int cols)
        {
            if (rows < 0 || rows > Int32.MaxValue || cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            float[][] z = new float[rows][];
            for (int i = 0; i < rows; i++)
                z[i] = new float[cols];
            return z;
        }

        /// <summary>
        /// Create one dimensional array of double values.
        /// </summary>
        /// <param name="cols">Number of elements (columns) in array.</param>
        /// <returns>One dimensional array of doubles.</returns>
        public static double[] CreateDouble1D(int cols)
        {
            if (cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            return new double[cols];
        }

        /// <summary>
        /// Create two dimensional array of double values.
        /// </summary>
        /// <param name="rows">Number of rows in array.</param>
        /// <param name="cols">Number of columns in array.</param>
        /// <returns>Two dimensional array of doubles.</returns>
        public static double[][] CreateDouble2D(int rows, int cols)
        {
            if (rows < 0 || rows > Int32.MaxValue || cols < 0 || cols > Int32.MaxValue) throw new ArgumentOutOfRangeException();

            double[][] z = new double[rows][];
            for (int i = 0; i < rows; i++)
                z[i] = new double[cols];
            return z;
        }
    }
}
